const mongoose = require('mongoose');
const orderModel=mongoose.model("orderModel")
const buyUsersModel=mongoose.model("buyUsersModel")
//第三层
// 删除
module.exports.deleteOrders = async (orderId)=>{
    const data = await mongoose.model('orderModel').deleteOne(orderId);
    return data;
    
}
//全部获取
module.exports.getOrders3=async ()=>{
    const data= await orderModel.find().populate("goodsId productName userId usersAddress usersPhoneNumber")
    // console.log('获取的数据',data)
    return data
    
}
//修改
module.exports.updataOrderS=async (orderId)=>{
    const data= await orderModel.find(orderId).populate("goodsId productName userId usersAddress usersPhoneNumber")
    return data
    
}
//确认修改
module.exports.setOrderDataS=async (newdata)=>{
    // console.log('进入第三层')
    return await orderModel.updateOne({_id:newdata._id},{show:newdata.show,status:newdata.status,remark:newdata.remark,number:newdata.number})

}
module.exports.setuserData=async (newdata)=>{
    console.log('进入第三层')
    return await buyUsersModel.updateOne({_id:newdata._id},{userAddress:newdata.userAddress,userPhoneNumber:newdata.userPhoneNumber})

}